package fictional.Common;

import java.util.Date;

/**
 * Parent class for social items which involves two characters and a date of interaction
 */
public abstract class SocialItem extends StorageItem implements Comparable<SocialItem>{

	private ShortCharacterItem sender;
	private ShortCharacterItem receiver;
	private Date date;
	
	protected SocialItem(int id, ShortCharacterItem sender, ShortCharacterItem receiver, Date date) {
		super(id);
		this.sender = sender;
		this.receiver = receiver;
		this.date = date;
	}	
	
	public Date getDate(){
		return date;
	}
	
	public void setDate(Date date) {
		this.date = date;
	}
	
	public ShortCharacterItem getSender(){
		return sender;
	}
	
	public ShortCharacterItem getReceiver(){
		return receiver;
	}
	
	@Override
	/*
	 * Comparator for SocialItems. Allows sorting from new to old
	 */
	public int compareTo(SocialItem s) {
		if (s.getId() == this.getId())
			return 0;
		return (s.getDate().compareTo(this.getDate())) < 1 ? -1 : 1;
	}
}
